package love.unknown.servlets;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Demo02Servlet extends HttpServlet {
    public Demo02Servlet() {
        System.out.println("正在实例化...");
    }

    @Override
    public void init() throws ServletException {
        System.out.println("正在初始化...");     //默认第一次接收请求时,实例化,初始化
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("正在服务..."+req.getRemoteAddr()+req.getHeader("user-agent"));
    }

    @Override
    public void destroy() {
        System.out.println("正在销毁...");
    }
}
